package com.shujia.batch

import java.io.InputStream
import scala.io.Source

object ZqZfIndexUtils {

  /**
   * 获取指标统计口径
   *
   */
  def getIndexMap: Map[String, List[String]] = {

    val imputStream: InputStream = this
      .getClass
      .getClassLoader//类加载器，
      //从resources目录下游通过文件名获取一个输入流
      .getResourceAsStream("zqzf_indexs.txt")

    //读取口径数据
    val indexList: List[String] = Source.fromInputStream(imputStream).getLines().toList

    //将数据展开
    val kvList: List[(String, List[String])] = indexList.map(line => {
      val split: Array[String] = line.split("-")
      val indexName: String = split(0)
      val kj: List[String] = split(1).split(",").toList
      (indexName, kj)
    })

    //转换成map集合
    kvList.toMap


  }

  def main(args: Array[String]): Unit = {
    val indexMap: Map[String, List[String]] = ZqZfIndexUtils.getIndexMap

    indexMap.foreach(println)
  }

}
